"https://api.map.baidu.com/place/v2/search?query=ATM机&tag=银行&region=北京&output=json&ak=您的ak"

import requests
import hashlib
import urllib.parse
import time

def location(AK, SK):
    base_url = "https://api.map.baidu.com/place/v2/search"
  
    # 生成SN签名
    query = {
        'query': "沙坪坝区陈家桥街道大学城北路43号A幢5-1号",
        'region': "重庆",
        'ak': AK,
        'timestamp': str(int(time.time())),
        'output': 'json'
    }
    encoded_str = urllib.parse.urlencode(query)
    raw_str = f"/place/v2/search?{encoded_str}{SK}"
    sn = hashlib.md5(urllib.parse.quote_plus(raw_str).encode()).hexdigest()
  
    # 带SN的请求URL
    url = f"{base_url}?{encoded_str}&sn={sn}"
  
    response = requests.get(url)
    print (response.json())
